-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[App Search] Add roleHasScopedEngines helper + small roles/
cleanup
#94038
Conversation
- in preparation for new scoped engines helper
export const roleHasScopedEngines = (roleType: RoleTypes): boolean => { | ||
const unscopedRoles = ['dev', 'editor', 'analyst']; | ||
return unscopedRoles.includes(roleType); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main new added utility/functionality (ported over from https://github.com/elastic/ent-search/blob/master/app/javascript/app_search/classes.ts#L10-L13)
* Transforms the `role` data we receive from the Enterprise Search | ||
* server into a more convenient format for front-end use | ||
*/ | ||
export const getRoleAbilities = (role: Account['role']): Role => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fn is the exact same as before, I just moved the type definitions out into types.ts
. The types are also the same as before
💚 Build SucceededMetrics [docs]Module Count
Async chunks
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for taking the extra time!
|
||
import { roleHasScopedEngines } from './'; | ||
|
||
describe('roleHasScopedEngines()', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not make this update for this PR, it's not worth running CI. Just noting that we usually don't add parens to the end of function names in describes.
describe('roleHasScopedEngines()', () => { | |
describe('roleHasScopedEngines', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha thanks Jason, I was totally about to smash commit suggestion before seeing the do not (italics totally worked). This is an accidental copypaste carry over from
Line 54 in 1969104
describe('can()', () => { |
- I think I originally added the
()
because it's a function helper within a 'class'/obj that has static vars mixed in with fn's 🤔 not sure if the()
is helpful in those scenarios - agreed they're not helpful for utility files where everything is a function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@scottybollinger if you're down, feel free to make Jason's suggested copy change in a future role mappings PR!
…elastic#94038) * Split out roles/ into separate files - in preparation for new scoped engines helper * Add new roleHasScopedEngines helper
…#94038) (#94144) * Split out roles/ into separate files - in preparation for new scoped engines helper * Add new roleHasScopedEngines helper Co-authored-by: Constance <[email protected]>
Summary
@scottybollinger needs this helper for his App Search role mappings work.
Thanks to his great suggestion in #94032 (comment), I've moved this out of
myRole
to its own separate utility fn, and split up therole/
folder some (into separate utils+types)Checklist